
#define ONMACVM

using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using FlatRedBall;
using FlatRedBall.Graphics;

using FlatRedBall.Input;
using FlatRedBall.Instructions;

#if ONMACVM
using fbDeprofiler;
#endif
using Gnome.Screens;
using FlatRedBall.Audio;

namespace Gnome
{
    /// <summary>
    /// This is the main type for your game
    /// </summary>

    public class Game1 : Microsoft.Xna.Framework.Game
    {
        private const int RESOLUTION_WIDTH = 1024;
        private const int RESOLUTION_HEIGHT = 768;
        private const bool SET_FULLSCREEN = false;

        GraphicsDeviceManager graphics;

        public Game1()
        {

#if ONMACVM
            DeProfiler.Run();
#endif
            graphics = new GraphicsDeviceManager(this);
            graphics.PreferredBackBufferHeight = 600;
            Content.RootDirectory = "Content";
        }

        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here
            Renderer.UseRenderTargets = false;
            FlatRedBallServices.InitializeFlatRedBall(this, graphics);
            FlatRedBallServices.GraphicsOptions.IsFullScreen = SET_FULLSCREEN;
            FlatRedBallServices.GraphicsOptions.SetResolution(RESOLUTION_WIDTH, RESOLUTION_HEIGHT);
			GlobalContent.Initialize();
            
			Screens.ScreenManager.Start(typeof(Gnome.Screens.SplashScreen).FullName);

            AudioManager.Initialize(@"Content\Audio\gnomemansland.xgs",
                 @"Content\Audio\Wave Bank.xwb", @"Content\Audio\Sound Bank.xsb");

            base.Initialize();

            string contentManagerName = "ContentManager";
            Song song =
               FlatRedBallServices.Load<Song>(@"Content/TitleMusic", contentManagerName);

            Microsoft.Xna.Framework.Media.MediaPlayer.Volume = 0.25f;
            Microsoft.Xna.Framework.Media.MediaPlayer.Play(song);
            Microsoft.Xna.Framework.Media.MediaPlayer.IsRepeating = true;
        }


        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            FlatRedBallServices.Update(gameTime);
            ScreenManager.Activity();

            base.Update(gameTime);
        }

        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            FlatRedBallServices.Draw();

            base.Draw(gameTime);
        }
    }
}
